package com.night.permManager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.night.common.entity.administration.Teacher;
import com.night.common.entity.role.Role;
import com.night.common.entity.student.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @ClassName: RoleMapper
 * @Description: //TODO
 * @author: dz
 * @date: 2022-08-31-14:24
 */
public interface RoleMapper extends BaseMapper<Role> {

    //根据角色id 查角色信息带出菜单
    @Select("select * from ss_role where id=#{id}")
    @Results({
            @Result(column = "id", property = "id", id = true),
            @Result(column = "id", property = "menuPerms", many = @Many(select = "com.night.permManager.mapper.MenuPermMapper.getByRoleId"))
    })
    Role getById(int id);

    @Select("select * from ss_role")
    List<Role> getRoles();

    @Select("select id,student_number studentNumber,password from ss_student where student_number = #{studentNumber}")
    Student getStudentByStudentNumber(@Param("studentNumber") String studentNumber);

    @Select("select id,teacher_number teacherNumber,password from ss_teacher where teacher_number = #{teacherNumber}")
    Teacher getStudentByTeacherNumber(@Param("teacherNumber") String teacherNumber);
}
